//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef pair<int,int> pii;

int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	int n, m, sum, x, y, i, j;
	priority_queue< pii > q;
	pii p;
	
	scanf("%d%d", &n, &m);
	for( i=0 ; i<m ; ++i ){
		scanf("%d%d", &x, &y);
		q.push( make_pair(y,x) );
	}
	sum=0;
	for(j=0;j<n&&q.size();){
		p=q.top();q.pop();
		if(p.second+j<=n){
			j+=p.second;
			sum+=p.second*p.first;
		}
		else{
			sum+=p.first*(n-j);
			j=n;
		}
	}
	printf("%d", sum);
	return 0;
}

